package com.sunsys.hbase.htable.example;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTableInterface;

public class HTableInstanceCreationExample1 {

	public static void putData() {

		Configuration conf = null;
		String tableName = "users";
		HTableInterface hTableInterface = null;
		
		try {
			conf = HBaseConfiguration.create();
			/* getting a HTable instance in this approach is very expensive
			 * it is better to use HtablePool (connection pool) */
			hTableInterface = new HTable(conf, tableName);
			
		}catch(IOException e1) {
			e1.printStackTrace();
		}finally {
			try {
				if(hTableInterface != null) {
					hTableInterface.close();
				}
			}catch(IOException e2){
				;
			}
		}
	}
	
	public static void main(String []args) {
		putData();
		System.out.println("Thank you");
	}
	
}
